package com.guigu.pd.auth.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guigu.pd.auth.entity.PageVo;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.pd.auth.dao.AuthRoleDao;
import com.guigu.pd.auth.entity.AuthRoleEntity;
import com.guigu.pd.auth.service.AuthRoleService;


@Service("authRoleService")
public class AuthRoleServiceImpl extends ServiceImpl<AuthRoleDao, AuthRoleEntity> implements AuthRoleService {
    @Override
    public PageVo<AuthRoleEntity> queryRoleEntity(AuthRoleEntity authRoleEntity, int pageno, int pagesize) {
        //组装分页
        IPage<AuthRoleEntity> page = new Page<AuthRoleEntity>(pageno,pagesize);

        //组装条件
        QueryWrapper<AuthRoleEntity> queryWrapper = new QueryWrapper<AuthRoleEntity>();

        //根据名字模糊查询
        if(StringUtils.isNotBlank(authRoleEntity.getName())) {
            queryWrapper.like("name", authRoleEntity.getName());
        }

        IPage<AuthRoleEntity> pageinfo = this.page(page,queryWrapper);

        PageVo<AuthRoleEntity> pageVo =new PageVo<AuthRoleEntity>();
        pageVo.setRows(pageinfo.getRecords());
        pageVo.setTotal(pageinfo.getTotal());
        return pageVo;
    }

//    @Override
//    public PageUtils queryPage(Map<String, Object> params) {
//        IPage<AuthRoleEntity> page = this.page(
//                new Query<AuthRoleEntity>().getPage(params),
//                new QueryWrapper<AuthRoleEntity>()
//        );
//
//        return new PageUtils(page);
//    }

}